﻿using System;
using System.Runtime.Serialization;

namespace RentIt06
{
    [DataContract]
    public struct Media
    {
        internal Media(db.Media m) {
            Title = m.title;
            Author = m.author;
            Category = m.category;
            ReleaseDate = m.releaseDate;
            RentingPrice = m.rentingPrice;
            PurchasePrice = m.purchasePrice;
            CanBeBought = m.canBeBought;
            CanBeRented = m.canBeRented;
            Id = m.id;
            Filename = m.fileName;
            MediaType = (MediaType) Enum.Parse(typeof (MediaType), m.MediaType1.name);
            IsPublished = m.published;
            FileLenght = m.bytes;
        }
        [DataMember]
        public string Title;
        [DataMember]
        public string Author;
        [DataMember]
        public string Category;
        [DataMember]
        public DateTime ReleaseDate;
        [DataMember]
        public decimal RentingPrice;
        [DataMember]
        public decimal PurchasePrice;
        [DataMember]
        public bool CanBeBought;
        [DataMember]
        public bool CanBeRented;
        [DataMember]
        public readonly int Id;
        [DataMember]
        public string Filename;
        [DataMember]
        public MediaType MediaType;
        [DataMember]
        public bool IsPublished;
        [DataMember] 
        public long FileLenght;
    }
}